/**
 * Witontek.com.
 * Copyright (c) 2012-2016 All Rights Reserved.
 */
package test.list;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author Long
 * @version $Id: SubList.java, v 0.1 2016年10月8日 下午3:47:59  xiaolong.ma  Exp $
 */
public class SubList {

    /**
     * 
     * @param args
     */
    public static void main(String[] args) {

        int maxNum = 10;
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 0; i < 7; i++) {
            list.add(i);
        }
        List<List<Integer>> newList = new ArrayList<List<Integer>>();
        int page = list.size() / maxNum;
        int r = list.size() % maxNum;

        for (int i = 0; i < page; i++) {
            List<Integer> subList = list.subList(i * maxNum, (i + 1) * maxNum);
            newList.add(subList);

        }
        if (r > 0) {
            List<Integer> subList = list.subList(page * maxNum, list.size());
            newList.add(subList);
        }

        for (int i = 0; i < newList.size(); i++) {
            List<Integer> list1 = newList.get(i);
            for (int j = 0; j < list1.size(); j++) {
                System.out.println(list1.get(j));
            }
            System.out.println("......" + i);
        }

    }

}
